package com.lesson26.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class XmlDataController {

	@RequestMapping(value={"/xml/retXml"})
	public String retXml(){
		
		 String body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>       "
				 +"<bookstore>                                  "
				 +"	<book>                                     "
				 +"	  <title lang=\"eng\">Harry Potter</title>   "
				 +"	  <price>29.99</price>                     "
				 +"	  <author>java乐园</author>                "
				 +"	</book>                                    "
				 +"	<book>                                     "
				 +"	  <title lang=\"eng\">Learning XML</title>   "
				 +"	  <price>39.95</price>                     "
				 +"	   <author>架构师知音</author>             "
				 +"	</book>                                    "
				 +"</bookstore>                                 ";
		 return body;
	}

	@RequestMapping(value={"/xml/revXMl"})
	public Map<String, Object> revXMl(String data){
		Map<String, Object> results = new HashMap<String, Object>();
		 results.put("code", "000000");
		 results.put("msg", "success");
		 System.out.println("revXMl data = "+ data);
		 return results;
	}
	
	@RequestMapping(value={"/xml/retXml2"})
	public String retXml2(){
		
		 String body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>       "
				 +"<bookstore>                                  "
				 +"	<book>                                     "
				 +"	  <title lang=\"eng\">Harry Potter</title>   "
				 +"	  <price>29.99</price>                     "
				 +"	  <author>java乐园</author>                "
				 +"	</book>                                    "
				 +"	<book>                                     "
				 +"	  <title lang=\"eng\">Learning XML</title>   "
				 +"	  <price>39.95</price>                     "
				 +"	   <author>架构师知音</author>             "
				 +"	</book>                                    "
				 +"                                 ";
		 return body;
	}
	
}
